home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 16 / CU Amiga Magazine's Super CD-ROM 16 (1997-10-16)(EMAP Images)(GB)[!][issue 1997-11].iso / CUCD / Utilities / EZCron / EZCron < prev    next >
Text File  |  1997-04-30  |  23KB  |  812 lines

  1. /* $VER: EZCron v2.21 by Jim Hines. ©1995-97 All Rights Reserved.
  2. ** EZCron is The Graphic User Interface for EZCrond, ©1994-1997 Jim Hines.
  3. ** Thanks must go to Gene Heskett for his help in coding some functions.
  4. ** Internet email me at <hines_j@iolinc.net>
  5. */
  6.  
  7.     LF= '0a'x
  8.     defaultevent = 'rx,ezcron:rexx/TalkingClock.rexx,hourly,daily,--/--/--,--/--/--,--:--,--:--,-,-,'
  9.  
  10.     SIGNAL ON ERROR 
  11.     SIGNAL ON IOERR
  12.     SIGNAL ON SYNTAX
  13.     SIGNAL ON HALT
  14.     OPTIONS FAILAT 20
  15.     OPTIONS RESULTS
  16.  
  17.     if ~show('L','rexxsupport.library') then
  18.            call addlib('rexxsupport.library', 0, -30)
  19.     
  20.     if ~show('L','rexxreqtools.library') then
  21.            call addlib("rexxreqtools.library", 0, -30, 0)
  22.  
  23.     if ~showlist('P','VAREXX') then do
  24.            address command 'run >nil: varexx'
  25.         call delay(25)
  26.     end
  27.  
  28.     address VAREXX
  29.     call openport('EZCRONPREFS')
  30.     load 'EZCron:EZC.gui EZCRONPREFS'
  31.     host = result
  32.     address value host
  33.     show editwindow
  34.     set startdate enddate disable
  35.  
  36. startup:
  37.     if showlist('P','EZCROND') then do
  38.         settext text '"Active"'
  39.     end
  40.     if ~showlist('P', 'EZCROND') then do
  41.         settext text '"Inactive"'
  42.     end
  43.  
  44. /* Read the prefs files for later reference */
  45.     if ~exists('EZCron:prefs/con.prefs') then convar = '>CON:50/100/400/100/CronTestEvent/Close'
  46.     else do
  47.         call open('confile','EZCron:Prefs/con.prefs','R')
  48.         convar = readln('confile')
  49.         call close('confile')
  50.     end
  51.  
  52.     if ~exists('EZCron:prefs/config.prefs') then configfile = 't:cron.config'
  53.     else do
  54.         call open('configprefs', 'EZCron:Prefs/config.prefs', 'R')
  55.         configfile = readln('configprefs')
  56.         call close('configprefs')
  57.     end
  58.  
  59. /* Create it if cron.config ~exists */
  60.     if ~exists('s:cron.config') then do
  61.         call message('Config file not found. Creating a new one.')
  62.         call open('cronfile','s:cron.config', 'W')
  63.         call writeln('cronfile', defaultevent)
  64.         call close('cronfile')
  65.     end
  66.  
  67. /* make sure it's not empty */
  68.     if exists('s:cron.config') then do
  69.         call open('cronfile','s:cron.config','R')
  70.         if readln('cronfile') = '' then do
  71.             call message('Your config contains no entries. Creating one.')
  72.             call writeln('cronfile', defaultevent)
  73.         end
  74.     call close('cronfile')
  75.     end
  76.     drop defaultevent
  77.  
  78.     address command 'copy s:cron.config' configfile
  79.  
  80. eventparse:
  81.     address value host  /* this is so the correct window's buttons work after closing other windows */
  82.     drop result ev et rng1 rng2 ed sd edt arg1 sfx txt
  83.  
  84.     do forever
  85.         setlist selectevent clear
  86.         event. = 0
  87.         
  88.         if ~open('cronfile', 's:cron.config', 'R') then do
  89.             call message('Config file not found. Creating a new one.')
  90.             call AC_New()
  91.         end
  92.         
  93.         errors = 0
  94.         do until eof('cronfile')
  95.             linein = readln('cronfile')
  96.             parse var linein line ';'
  97.             next = event.0 + 1
  98.     
  99.             parse var line event.next.command','event.next.pargs','event.next.time',',
  100.             event.next.date','event.next.startdate','event.next.enddate',',
  101.             event.next.rng1','event.next.rng2','event.next.sfx','event.next.txt','
  102.  
  103.             event.next.date = translate(event.next.date, 'abcdefghijklmnopqrstuvwxyz',,
  104.                             'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  105.                             /* THE ABOVE TRANSLATES THE DATE TO LOWERCASE IF NOT NUMERIC */
  106.  
  107.             event.next.time = translate(event.next.time, 'abcdefghijklmnopqrstuvwxyz',,
  108.                             'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  109.                             /* THE ABOVE TRANSLATES THE TIME TO LOWERCASE IF NOT NUMERIC */
  110.  
  111.             event.next.txt = strip(event.next.txt) /* This Gets rid of the leading & trailing spaces in the LAST variable
  112.                                                       If new fields are added, the variable must be changed to reflect this */
  113.     
  114.             if line ~= '' then do  /* This keeps the commented out lines from appearing */
  115.                 setlist selectevent event.next.command
  116.             end
  117.         
  118.             select
  119.                 when event.next.command = '' then iterate
  120.                 when event.next.command = '' then do
  121.                     iterate
  122.                 end
  123.                 otherwise event.0 = next
  124.             end
  125.         end
  126.         settext eventcount event.0  /* for event counter */
  127.         call close('cronfile')
  128.         call waitforpkt()
  129.     end
  130.  
  131. /* ===== END OF PARSE  */
  132.  
  133. waitforpkt:
  134.     do forever
  135.         call waitpkt('EZCRONPREFS')    /* Wait for a message from Varexx */
  136.         packet = getpkt('EZCRONPREFS')        /* Get the message */
  137.  
  138.            if packet ~= '00000000'x then do /* This is not a null message */
  139.             call reply(packet, 0)  /* FOR AREXX MESSAGES */
  140.             class  = getarg(packet)    /* Get the information about the message */
  141.             type = word(class, 1)
  142.             msg = substr(class, 12,100)
  143.  
  144.             if class = eventtype then call eventtype()
  145.             if class = closewindow then call exiting()
  146.             if class = quit then call exiting()
  147.             if class = prefsgad then call prefsgad()
  148.             if class = edit then call edit()
  149.             if class = testevent then call testevent()
  150.             if class = AC_New then call AC_New()
  151.             if class = arg1gad then call arggad()
  152.             if class = sfxgad then call sfxgad()
  153.             if class = datefields then call mydate()
  154.             if class = timefields then call mytime()
  155.             if class = purgegad then call purge()
  156.             if class = indis then call indis()
  157.             if class = update then call update()
  158.             if class = addevent then call addevent()
  159.             if class = addefault then call addefault()
  160.             if class = delete_event then call deleteevent()
  161.             if class = ac_toggle then call ac_toggle()
  162.             if class = clockon then call clockon()
  163.             if class = refresh then call refresh()
  164.             if class = about then call about()
  165.             if class = copy then call copy()
  166.             if msg ~= '' & type = 'SELECTEVENT' then call selectevent()
  167.         end
  168.     end
  169.     return
  170.  
  171. /* CLASSES ROUTINES */
  172. copy:
  173.     address command 'copy s:cron.config s:cron.config.bak'
  174.     return
  175.  
  176. about:
  177.     call rtezrequest('EZCron v2.21'||LF||'©1995-1997 Jim Hines'||LF||'EZCron is emailware.'||LF||'If you use it, please lemme know.','Well Alrighty Then','About EZCron','rtez_flags=ezreqf_centertext rt_reqpos = reqpos_centerscr',)
  178.     return
  179.  
  180. eventtype:
  181.     call rtezrequest('Please choose what type'||LF||'of  Event you would like.', 'Program|Cancel|Reminder', ,)
  182.     if rtresult == 1 then call getfile()
  183.     if rtresult == 2 then call waitforpkt()
  184.     if rtresult == 0 then call txtgad()
  185.     return
  186.  
  187. clockon:
  188.     if exists('ezcron:prefs/clock.prefs') then do
  189.         call open('clockpref', 'EZCron:Prefs/clock.prefs', 'R')
  190.         clockvar = readln('clockpref')
  191.         call close('clockpref')
  192.         if clockvar = 'DIGITAL' then clockvar = 'digital format 2'
  193.         if clockvar = 'ANALOG' then clockvar = 'seconds'
  194.     end
  195.     else clockvar = 'seconds'
  196.     address command 'run <>nil: clock' clockvar
  197.     return
  198.  
  199. AC_Toggle:
  200.     if ~showlist('P', 'EZCROND') then do
  201.         address command 'run <>nil: rx EZCron:EZCronD'
  202.     end    
  203.     else
  204.     if showlist('P', 'EZCROND') then do    
  205.         address command 'run <>nil: rx EZCron:EZCronD'
  206.         settext text '"Wait..Exiting"'
  207.         set ac_toggle disable
  208.     end
  209.     return
  210.  
  211. edit:
  212.     if ~exists('EZCron:prefs/txted.prefs') then address command 'ed s:cron.config'
  213.     if exists('EZCron:prefs/txted.prefs') then do
  214.         call open('edconfig', 'EZCron:prefs/txted.prefs', 'R')
  215.         linein = readln('edconfig')
  216.         address command linein 's:cron.config'
  217.         call close('edconfig')
  218.     end
  219.     address command 'copy s:cron.config' configfile
  220.     call eventparse()
  221.  
  222. testevent:
  223.     if exists('EZCron:prefs/sfx.prefs') then do
  224.         call open('sfxconfig', 'EZCron:prefs/sfx.prefs', 'R')
  225.         sfxplayer = readln('sfxconfig')
  226.         call close('sfxconfig')
  227.     end
  228.  
  229.     read event
  230.     ev = RESULT
  231.     if left(ev,1) = '!' then ev = substr(ev,2,256)
  232.     
  233.     read arg1
  234.     arg1 = RESULT
  235.     if arg1 = '-' then arg1 = ''
  236.     
  237.     read sfx
  238.     fx = RESULT
  239.     if fx = '-' then fx = ''
  240.     
  241.     read txtstr
  242.     tx = result
  243.                 
  244.     if ev ~= textreminder then do
  245.         address command 'run' convar ev arg1
  246.     end
  247.     
  248.     if fx ~= '' then do
  249.         address command 'run >nil:' sfxplayer fx
  250.     end
  251.     
  252.     if ev = TEXTREMINDER then do
  253.         address command 'run >nil: rx >nil: ezcron:rexx/Reminder.rexx' tx
  254.         if showlist(h,SPEAK) then do
  255.             address command 'echo' '"'tx'"' '>speak:'
  256.         end
  257.     end
  258.     drop result ev et ed arg1 rng1 rng2 sfx txt
  259.     return    
  260.  
  261. selectevent:
  262.     read selectevent NUMBER
  263.     en = RESULT  /* en is the event number */
  264.  
  265.     settext event msg
  266.     set arg1 arg1gad enable
  267.     if msg = 'TEXTREMINDER' | msg = '!TEXTREMINDER' then do
  268.         set arg1 arg1gad disable
  269.     end
  270.     a = 0
  271.     if pos('##', event.en.date, 1) > 0 then do
  272.         a = 1
  273.     end
  274.     settext event_time event.en.time
  275.     settext event_date event.en.date
  276.     settext rng1 event.en.rng1
  277.     settext rng2 event.en.rng2
  278.     if event.en.date = 'range' | event.en.date = 'daily' | a = 1 then do
  279.         set startdate enddate enable
  280.     end
  281.     else do
  282.         set startdate enddate disable
  283.     end
  284.     settext startdate event.en.startdate
  285.     settext enddate event.en.enddate
  286.     settext arg1 event.en.pargs
  287.     settext rng1 event.en.rng1
  288.     settext rng2 event.en.rng2
  289.     settext sfx event.en.sfx
  290.     settext txtstr event.en.txt
  291.     drop a
  292.     return
  293.  
  294. getfile:
  295.     set arg1 arg1gad enable
  296.     clock = time('N')
  297.     clock2 = LEFT(clock,5)
  298.     filename = rtfilerequest('Sys:', , "Pick a File To Run",OK)
  299.     if filename = '' then call eventparse() /* Get out of routine */
  300.     settext event filename
  301.     settext event_time clock2
  302.     settext rng1 '--:--'
  303.     settext rng2 '--:--'
  304.     settext event_date Date(USA)
  305.     settext startdate '--/--/--'
  306.     settext enddate '--/--/--'
  307.     settext arg1 '-'
  308.     settext sfx '-'
  309.     settext txtstr '-'
  310.     return
  311.  
  312. AC_New:
  313.     if exists('EZCron:prefs/defev.prefs') then do
  314.         call open('prefs', 'EZCron:prefs/defev.prefs', 'R')
  315.         defevent = readln('prefs')
  316.         call close('prefs')
  317.     end
  318.     if ~exists('s:cron.config') then do
  319.         call open('MkCfg', 's:cron.config',W)
  320.         call writeln('MkCfg', defevent)
  321.         call close('MkCfg')
  322.     end
  323.     else 
  324.     call rtezrequest('A cron.config file already exists.'||LF||'Do you wish to overwrite it?.', '_Yes|_No', , 'rt_reqpos = reqpos_centerscr')
  325.     if rtresult == 1 then do
  326.         if exists('s:cron.config.old') then address command 'delete s:cron.config.old'
  327.         address command 'rename s:cron.config s:cron.config.old'
  328.         call open('MkCfg', 's:cron.config','W')
  329.         call writeln('MkCfg', defevent)
  330.         call close('MkCfg')
  331.     end
  332.     address command 'copy s:cron.config' configfile
  333.     call eventparse()
  334.     return
  335.     
  336. arggad:
  337.     argname = rtfilerequest('Sys:', , 'Pick a file argument',OK)
  338.     if argname = '' then argname = '-'
  339.     settext arg1 argname
  340.     return
  341.  
  342. sfxgad:
  343.     read sfx
  344.     sfxtxt = result
  345.     parse var sfxtxt device ':'
  346.     if device = '-' then device = 'sys'
  347.     argname = rtfilerequest(device':',, 'Pick a soundfile',OK,)
  348.     if argname = '' then argname = '-'
  349.     settext sfx argname
  350.     return    
  351.  
  352. txtgad:
  353.     read txtstr
  354.     txt = result
  355.     if txt = '-' then txt = '' 
  356.     argname = rtgetstring(txt,'Enter Reminder String', 'Reminder Requester', ,)
  357.     if argname = '' then call eventparse()
  358.     clock = time('N')
  359.     clock2 = LEFT(clock,5)
  360.     settext txtstr argname
  361.     settext event TextReminder
  362.     settext event_time clock2
  363.     settext event_date Date(USA)
  364.     settext startdate '--/--/--'
  365.     settext enddate '--/--/--'
  366.     set arg1 startdate enddate disable
  367.     settext arg1 '-'
  368.     settext sfx '-'
  369.     drop txt
  370.     return
  371.  
  372. prefsgad:
  373.     call openport('PREFSWINPORT')
  374.     spawn PREFSWINPORT
  375.     host2 = result
  376.     address value host2
  377.     show prefswindow
  378.     call prefs()
  379.     return
  380.  
  381. mydate:
  382.     call openport('DATEWINPORT')
  383.     spawn DATEWINPORT
  384.     host3 = result
  385.     address value host3
  386.     show datewindow
  387.     call datefields()
  388.     return
  389.  
  390. mytime:
  391.     call openport('TIMEWINPORT')
  392.     spawn TIMEWINPORT
  393.     host4 = result
  394.     address value host4
  395.     show timewindow
  396.     call timefields()
  397.     return
  398.  
  399. purge:
  400.     address command 'copy s:cron.config s:cron.config.old'
  401.     address command 'delete s:cron.config'
  402.     call open('dfile', 's:cron.config', 'W') /* create it again*/
  403.     call close('dfile')
  404.  
  405.     do i = 1 to event.0
  406.         if event.i.date = 'range' then event.i.date = event.i.enddate
  407.         parse var event.i.date month '/' day '/' year
  408.                     
  409.         if day ~= '' & if year ~= '' then do 
  410.             sortdate = '19'year''month''day
  411.             eventdate = date('C',sortdate,'S')        /* number of days since..*/
  412.             currentdate = date(S) /* 19951221 */
  413.             sortcurrent = date('C', currentdate, 'S') /* number of days since..*/
  414.             a = sortcurrent-eventdate
  415.             if a > 0 then event.i.command = delete  /* this are the files you DONT want to write */
  416.         end
  417.  
  418.         if event.i.command ~= delete then do
  419.             call open('dfile', 's:cron.config', 'a')
  420.             call writeln('dfile', event.i.command','event.i.pargs','event.i.time','event.i.date','event.i.startdate','event.i.enddate','event.i.rng1','event.i.rng2','event.i.sfx','event.i.txt',')
  421.             drop result
  422.         end
  423.         call close('dfile')
  424.         address command 'copy s:cron.config' configfile
  425.         drop a
  426.     end
  427.     call eventparse()
  428.     return
  429.     
  430. indis: /* Enable/Disable event */
  431.     read event
  432.     ev = result
  433.  
  434.     if left(ev,1) = '!' then do
  435.         ev = substr(ev,2,256) /* start with 2nd char and go 256 deep */
  436.         settext event ev
  437.         class = update
  438.     end
  439.     else do
  440.         settext event '!'ev
  441.         class = update
  442.     end
  443.     return
  444.  
  445. update: /* Modify */
  446.     read event
  447.     ev = result
  448.     if ev = '' then call message('No Event Field.')
  449.     if ev = '' then call eventparse()
  450.     if ev = 'None Selected' then call message('No Event Field.')
  451.     if ev = 'None Selected' then call eventparse()
  452.     read event_time
  453.     et = result
  454.     if et = '' then    call message('No Time Field.')
  455.     read event_date
  456.     ed = result
  457.     if ed = '' then call message('No Date Field.')
  458.     if et = 'startup' then do
  459.         settext event_date 'startup'
  460.         ed = 'startup'
  461.     end
  462.     read startdate
  463.     sd = result
  464.     if sd = '' then sd = '--/--/--'
  465.     read enddate
  466.     edt = result
  467.     if edt = '' then edt = '--/--/--'
  468.     read arg1
  469.     arg = result
  470.     if arg = '' then arg = '-'
  471.     read rng1
  472.     trng1 = result
  473.     if trng1 = '' then trng1 = '--:--'
  474.     read rng2
  475.     trng2 = result
  476.     if trng2 = '' then trng2 = '--:--'
  477.     read sfx
  478.     fx = result
  479.     if fx = '' then fx = '-'
  480.     read txtstr
  481.     rem = result
  482.     if rem = '' then rem = '-'    
  483.  
  484.     address command 'copy s:cron.config s:cron.config.old'
  485.     address command 'delete >NIL: s:cron.config'
  486.     call open('dfile', 's:cron.config', 'W') /* create it again*/
  487.     call close('dfile')
  488.  
  489.     read selectevent var h
  490.     call open('dfile', 's:cron.config', 'a')
  491.     do i = 1 to h.count
  492.         if en ~= i then do
  493.             call writeln('dfile', event.i.command','event.i.pargs','event.i.time','event.i.date','event.i.startdate','event.i.enddate','event.i.rng1','event.i.rng2','event.i.sfx','event.i.txt',')
  494.             drop result
  495.         end
  496.         else do
  497.             call writeln('dfile', ev','arg','et','ed','sd','edt','trng1','trng2','fx','rem',')
  498.         end
  499.     end
  500.     call close('dfile')
  501.     drop result ev et ed sd edt arg1 rng1 rng2 sfx txt
  502.     address command 'copy s:cron.config' configfile
  503.     call eventparse()
  504.  
  505. addevent:
  506.     read event
  507.     ev = result
  508.     if ev = '' then call message('No Event Field.')
  509.     if ev = 'None Selected' then call message('No Event Field.')
  510.                 
  511.     read event_time
  512.     et = result
  513.     if et = '' then    call message('No Time Field.')
  514.     
  515.     read event_date
  516.     ed = result
  517.     if ed = '' then call message('No Date Field.')
  518.  
  519.     read startdate
  520.     sd = result
  521.     if sd = '' then sd = '--/--/--'
  522.  
  523.     read enddate
  524.     edt = result
  525.     if edt = '' then edt = '--/--/--'
  526.         
  527.     read arg1
  528.     arg1 = result
  529.     if arg1 = '' then arg1 = '-'
  530.  
  531.     read rng1
  532.     rng1 = result
  533.     if rng1 = '' then rng1 = '--:--'
  534.  
  535.     read rng2
  536.     rng2 = result
  537.     if rng2 = '' then rng2 = '--:--'
  538.     
  539.     read sfx
  540.     sfx = result
  541.     if sfx = '' then sfx = '-'
  542.     
  543.     read txtstr
  544.     txt = result
  545.     if txt = '' then txt = '-'
  546.                 
  547.     if ev = '' then call eventparse()
  548.     if ev = 'None Selected' then call eventparse()
  549.     if et = '' then call eventparse()
  550.     if ed = '' then call eventparse()
  551.  
  552.     if et = 'startup' then do
  553.         settext event_date 'startup'
  554.         ed = 'startup'
  555.     end
  556.  
  557.     call open('dfile', 's:cron.config', 'A')
  558.     call writeln('dfile', ev','arg1','et','ed','sd','edt','rng1','rng2','sfx','txt',')
  559.     call close('dfile')
  560.     drop result ev et ed sd edt arg1 rng1 rng2 sfx txt
  561.     address command 'copy s:cron.config' configfile
  562.     call eventparse()
  563.             
  564. addefault:
  565.     read event
  566.     ev = result
  567.     if ev = '' then call message('No Event Field.')
  568.     if ev = 'None Selected' then call message('No Event Field.')
  569.     if ev = '' then call eventparse()
  570.     if ev = 'None Selected' then call eventparse()
  571.     if et = '' then call eventparse()
  572.     if ed = '' then call eventparse()
  573.  
  574.     address command 'delete ezcron:prefs/defev.prefs'
  575.     call open('dfile', 'ezcron:prefs/defev.prefs', 'W')
  576.     call writeln('dfile', ev','event.en.pargs','event.en.time','event.en.date','event.en.startdate','event.en.enddate','event.en.rng1','event.en.rng2','event.en.sfx','event.en.txt',')
  577.     call close('dfile')
  578.     drop result ev 
  579.     call eventparse()
  580.     return
  581.  
  582. deleteevent:
  583.     address command 'copy s:cron.config s:cron.config.old'
  584.     address command 'delete >NIL: s:cron.config'
  585.     call open('dfile', 's:cron.config', 'W') /* create it again*/
  586.     call close('dfile')
  587.  
  588.     read event_time
  589.     et = result
  590.     read selectevent var h
  591.     call open('dfile', 's:cron.config', 'A')
  592.     do n = 1 to h.count
  593.         if en ~= n then do
  594.             call writeln('dfile', h.n','event.n.pargs','event.n.time','event.n.date','event.n.startdate','event.n.enddate','event.n.rng1','event.n.rng2','event.n.sfx','event.n.txt',')
  595.         end
  596.     end
  597.     call close('dfile')
  598.     address command 'copy s:cron.config' configfile
  599.     
  600.     settext event 'None Selected'
  601.     settext event_time 'NA'
  602.     settext event_date 'NA'
  603.     settext startdate '--/--/--'
  604.     settext enddate '--/--/--'
  605.     settext arg1 '-'
  606.     settext rng1 '--:--'
  607.     settext rng2 '--:--'
  608.     settext sfx '-'
  609.     settext txtstr '-'
  610.     call eventparse()
  611.  
  612. refresh:
  613.     if showlist('P', 'EZCROND') then do
  614.         settext text '"Active"'
  615.     end
  616.     if ~showlist('P', 'EZCROND') then do
  617.         settext text '"Inactive"'
  618.     end
  619.     set ac_toggle enable
  620.     call eventparse()
  621.     return
  622.  
  623. prefs:
  624.     do forever
  625.         call waitpkt('PREFSWINPORT')    /* Wait for a message from Varexx */
  626.         packet = getpkt('PREFSWINPORT')        /* Get the message */
  627.     
  628.         if packet ~= '00000000'x then do /* This is not a null message */
  629.             class  = getarg(packet)    /* Get the information about the message */
  630.                type = word(class, 1)
  631.             msg = substr(class, 11,25)
  632.  
  633.             if class = 'CLOSEWINDOW PrefsWindow' then do
  634.                 hide
  635.                 address value host
  636.                 call waitforpkt()
  637.             end
  638.  
  639.             if class = texteditor then do
  640.                 editor = rtfilerequest('Sys:', , "Pick a text editor",OK, "rt_reqpos = reqpos_centerscr")
  641.                 if rtresult == 0 then call prefs() /*This get out of the edprefs function */
  642.                 call open('edconfig','EZCron:prefs/txted.prefs', 'W')
  643.                 call writeln('edconfig', editor)
  644.                 call close('edconfig')
  645.                 drop editor
  646.             end
  647.                 
  648.             if class = sfxplayer then do
  649.                 player = rtfilerequest('Sys:', , 'Pick a sound player',OK, 'rt_reqpos = reqpos_centerscr')
  650.                 if rtresult == 0 then call prefs() /*This get out of the edprefs function */
  651.                 call open('edconfig','EZCron:prefs/sfx.prefs', 'W')
  652.                 call writeln('edconfig', player)
  653.                 call close('edconfig')
  654.                 drop player
  655.             end
  656.  
  657.             if class = conselect then do
  658.                 console = rtgetstring(convar,'Enter Output String', 'Test Output Requester', ,)
  659.                 if console ~= '' then convar = console
  660.                 if rtresult == 0 then call prefs() /*This get out of the edprefs function */
  661.                 call open('conconfig','EZCron:prefs/con.prefs', 'W')
  662.                 call writeln('conconfig', console)
  663.                 call close('conconfig')
  664.                 drop console
  665.             end
  666.  
  667.             if class = clockprefs then do
  668.                 call rtezrequest('Pick a clock type.', 'Analog|Cancel|Digital', ,)
  669.                 if rtresult == 1 then clockvar = analog
  670.                 if rtresult == 2 then call prefs()
  671.                 if rtresult == 0 then clockvar = digital
  672.                 call open('ckconfig','EZCron:prefs/clock.prefs', 'W')
  673.                 call writeln('ckconfig', clockvar)
  674.                 call close('ckconfig')
  675.                 drop clockvar
  676.             end
  677.  
  678.             if class = configprefs then do
  679.                 configrt = rtgetstring(configfile,'Enter Path for cron.config', 'cron.config prefs', ,)
  680.                 if configrt ~= '' then configfile = configrt
  681.                 if rtresult == 0 then call prefs() /*This get out of the edprefs function */
  682.                 call open('configpref','EZCron:prefs/config.prefs', 'W')
  683.                 call writeln('configpref', configrt)
  684.                 call close('configpref')
  685.                 drop configrt
  686.                 call rtezrequest('If you changed the path,'||LF||'you must restart the daemon.','Okay,!','EZCron ERROR','rt_reqpos = reqpos_centerscr rtez_flags=ezreqf_centertext',)
  687.             end
  688.         call prefs()
  689.         end    
  690.     end
  691.  
  692. datefields:
  693.     do forever
  694.         call waitpkt('DATEWINPORT')    /* Wait for a message from Varexx */
  695.         packet = getpkt('DATEWINPORT')        /* Get the message */
  696.     
  697.         if packet ~= '00000000'x then do /* This is not a null message */
  698.             class  = getarg(packet)    /* Get the information about the message */
  699.                type = word(class, 1)
  700.             msg = substr(class, 11,25)
  701.  
  702.             if class = once then field = Date(USA)
  703.             if class = daily then call daterange('daily')
  704.             if class = monthly then field = 'Monthly-'right(date(S),2)  /* Monthly-13 */ 
  705.             if class = sunday then field = 'Sunday'
  706.             if class = monday then field = 'Monday'
  707.             if class = tuesday then field = 'Tuesday'
  708.             if class = wednesday then field = 'Wednesday'
  709.             if class = thursday then field = 'Thursday'
  710.             if class = friday then field = 'Friday'
  711.             if class = saturday then field = 'Saturday'
  712.             if class = sunday then field = 'Sunday'
  713.             if class = weekdays then field = 'Weekdays'
  714.             if class = weekends then field = 'Weekends'
  715.             if class = every_nn_dd then field = 'Every_3_Fri'
  716.             if class = dspecial then call daterange('##/##/##')
  717.             if class = 'CLOSEWINDOW DateWindow' then do
  718.                 hide
  719.                 address value host
  720.                 call waitforpkt()
  721.                 return
  722.             end
  723.             if field ~= '' then call fillindate()
  724.             return
  725.         end
  726.     end
  727.  
  728. daterange:
  729.     hide
  730.     address value host
  731.     settext event_date arg(1)
  732.     set startdate enddate enable
  733.     settext startdate '--/--/--'    
  734.     settext enddate '--/--/--'
  735.     call waitforpkt()
  736.     return
  737.     
  738. timefields:
  739.     do forever
  740.         call waitpkt('TIMEWINPORT')    /* Wait for a message from Varexx */
  741.         packet = getpkt('TIMEWINPORT')        /* Get the message */
  742.     
  743.         if packet ~= '00000000'x then do /* This is not a null message */
  744.             class  = getarg(packet)    /* Get the information about the message */
  745.                type = word(class, 1)
  746.             msg = substr(class, 11,25)
  747.  
  748.             if class = timeonce then field = LEFT(time('N'),5)
  749.             if class = minute then field = 'Minute'
  750.             if class = five_min then field = 'Five_Min'
  751.             if class = ten_min then field = 'Ten_Min'
  752.             if class = quarterly then field = 'Quarterly'
  753.             if class = twenty_min then field = 'Twenty_Min'
  754.             if class = thirty_min then field = 'Thirty_Min'
  755.             if class = hourly then field = 'Hourly'
  756.             if class = shour then field = '##:'substr(time('N'),4,2)
  757.             if class = startev then field = 'startup'
  758.             if class = 'CLOSEWINDOW TimeWindow' then do
  759.                 hide
  760.                 address value host
  761.                 call waitforpkt()
  762.                 return
  763.             end
  764.             if field ~= '' then call fillintime()
  765.             return
  766.         end    
  767.     end
  768.  
  769. fillindate:
  770.     hide
  771.     address value host
  772.     settext event_date field
  773.     settext startdate '--/--/--'
  774.     settext enddate '--/--/--'
  775.     set startdate enddate disable
  776.     call waitforpkt()
  777.     return
  778.  
  779. fillintime:
  780.     hide
  781.     address value host
  782.     settext event_time field
  783.     settext rng1 '--:--'
  784.     settext rng2 '--:--'
  785.     call waitforpkt()
  786.     return
  787.  
  788. helpmessage: procedure
  789.     call rtezrequest(arg(1),'Okay!','EZCron Online Help','rtez_flags=ezreqf_centertext',)
  790.     return
  791.  
  792. message: procedure
  793.     call rtezrequest(arg(1),'Okay!','EZCron ERROR','rt_reqpos = reqpos_centerscr rtez_flags=ezreqf_centertext',)
  794.     return
  795.  
  796. syntax:
  797. ioerr:
  798. error:
  799.     errorrc = RC
  800.     call closeport('EZCRONPREFS')
  801.     call rtezrequest('EZCron has exited with an error'||LF||'Line' SIGL ERRORTEXT(errorrc),'Okay!','EZCron FATAL ERROR','rt_reqpos = reqpos_centerscr rtez_flags=ezreqf_centertext',)
  802.     call exiting()
  803.  
  804. exiting:
  805.     hide unload        /* Hide the window and unload the gui */
  806.     call closeport('EZCRONPREFS')
  807.     address command 'run >nil: vxc'
  808.     address command 'run >nil: vxc'
  809.     address command 'run >nil: vxc'
  810.     address command 'run >nil: avail flush'    
  811.     exit
  812.